package design.mode.memento.item1;

import java.util.Scanner;

/**
 * /**
 *
 * @author ZhongMingde on 2021/11/20
 */

public class ApplicationMain {

  public static void main(String[] args) {
    InputText inputText = new InputText();
    SnapShotHolder snapShotHolder = new SnapShotHolder();
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()){
      String input = scanner.next();
      if (input.equals(":list")){
        System.out.println(inputText.getText());
      }else if (input.equals(":undo")){
        InputText snapshot = snapShotHolder.popSnapshot();
        inputText.setText(snapshot.getText());
      }else {
        snapShotHolder.pushSnapshot(inputText);
        inputText.append(input);
      }
    }
  }
}
